package cn.ad.server.persistence.dao;

import cn.ad.server.domain.ad.PubSite;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface PubSiteDao {
	
	
	@Results(value = { 
			@Result(column = "id", property = "id", id=true),
			@Result(column = "supplier_id", property = "supplier.id"),
			@Result(column = "name", property = "name"),
			@Result(column = "url", property = "url"),
			@Result(column = "create_time", property = "createTime"),
			@Result(column = "update_time", property = "updateTime") })
	@Select("select * from pub_site")
	List<PubSite> findAll();
	
	@Results(value = { 
			@Result(column = "id", property = "id", id=true),
			@Result(column = "supplier_id", property = "supplier.id"),
			@Result(column = "name", property = "name"),
			@Result(column = "url", property = "url"),
			@Result(column = "create_time", property = "createTime"),
			@Result(column = "update_time", property = "updateTime") })
	@Select("select * from pub_site where update_time >= #{value}")
	List<PubSite> findAfterTime(String warmUpTime);

	@Results(value = { 
			@Result(column = "id", property = "id", id=true),
			@Result(column = "supplier_id", property = "supplier.id"),
			@Result(column = "name", property = "name"),
			@Result(column = "url", property = "url"),
			@Result(column = "create_time", property = "createTime"),
			@Result(column = "update_time", property = "updateTime") })
	@Select("select * from pub_site where id = #{id}")
	PubSite findById(long id);

	@Results(value = { 
			@Result(column = "id", property = "id", id=true),
			@Result(column = "supplier_id", property = "supplier.id"),
			@Result(column = "name", property = "name"),
			@Result(column = "url", property = "url"),
			@Result(column = "create_time", property = "createTime"),
			@Result(column = "update_time", property = "updateTime") })
	@Select("select * from pub_site where id = #{id} and status = #{status}")
	PubSite selectById(@Param("id")long id, @Param("status")int status);
}
